package copyengine.utils.tick.node
{

	public final class AnimationTickDataWarp
	{
		private var _callBackFunction:Function;

		private var _totalFrame:int = -1;
		private var _callBackPercent:int = -1;
		private var _callBackFrame:int = -1;

		public function AnimationTickDataWarp()
		{
		}


		/**
		 *执行当前Data的Tick
		 * @param _currentTickFrame		当前Tick到的帧数
		 * @return									<b>True:</b>当前触发了回调，可以Dispose
		 *
		 */
		public function tick(_currentTickFrame:int):Boolean
		{
			if (_currentTickFrame == _callBackFrame)
			{
				_callBackFunction && _callBackFunction();
				_callBackFunction = null;
				return true;
			}
			return false;
		}

		public function dispose():void
		{
			_callBackFunction = null;
		}

		/**
		 * <b>设置当前Tick的TotalFrame</b></br>
		 * TotalFrame会在开始Tick之前设置
		 * <li>如果为LazyLoadObject则会先添加LoadComplateCallBack,在取得Callback后即可取得TotalFrame然后开始Tick流程
		 */
		public function set totalFrame(value:int):void
		{
			_totalFrame = value;

			//在设置了CallBackPercent,但是没有设置CallbackFrame的情况下
			//设置CallbackFrame
			if (_callBackPercent > 0 && _callBackPercent < 100 && _callBackFrame < 0)
			{
				_callBackFrame = _callBackPercent * 0.01 * _totalFrame;
			}
		}

		public function set callBackFunction(value:Function):void
		{
			_callBackFunction = value;
		}

		public function set callBackPercent(value:int):void
		{
			_callBackPercent = value;
		}

		public function set callBackFrame(value:int):void
		{
			_callBackFrame = value;
		}

	}
}
